<HTML><HEAD><TITLE>lock_pass(+)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Modules</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>lock_pass(+)</H1>
Locks access to internals of the current module
<H2>Description</H2>
    Used to forbid access from outside the current module to its internals,
    except through the module interface (i.e. its exports).
<P>
    This primitive is usually used a directive in the source code of the
    module to be locked.
<P>
    A module locked with lock_pass/1 can be unlocked using unlock/2, and
    giving the same pass-string that was used in locking.  The pass-string
    can be changed by calling lock_pass/1 again from within the module.
<P>

<H3>Modes and Determinism</H3><UL>
<LI>lock_pass(+) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H2>Examples</H2>
<PRE>
    % After compiling the following code:
     :- module(m).
     :- export pub/0.
     pub :- writeln(pub).
     priv :- writeln(priv).
     :- lock_pass("secret").


    ?- module(m).
    trying to access a locked module in module(m)

    ?- call(pub) @ m.
    pub
    yes.

    ?- call(priv) @ m.
    trying to access a locked module in priv

    ?- assert(foo) @ m.
    trying to access a locked module in assert_(foo, m)

    ?- unlock(m, "secret").
    yes.

    ?- call(priv) @ m.
    priv
    yes.

    ?- assert(foo) @ m.
    yes.

</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/modules/lock-0.html">lock / 0</A>, <A HREF="../../kernel/modules/unlock-2.html">unlock / 2</A>, <A HREF="../../kernel/modules/get_module_info-3.html">get_module_info / 3</A>
</BODY></HTML>
